package com.barras;

import java.util.ArrayList;
import java.util.List;

import org.achartengine.ChartFactory;
import org.achartengine.chart.BarChart.Type;
import org.achartengine.renderer.SimpleSeriesRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint.Align;
import android.view.View;

public class StackedBar extends abstractChart
{

	@Override
	public String getName() {return "Ventas";}

	@Override
	public String getDesc() {return "Ventas en barras";}

	@Override
	public Intent ejecutar(Context context)
	{
		String[] titles = new String[] { "2008", "2007" };
	    List<double[]> values = new ArrayList<double[]>();
	    values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200, 22030, 21200, 19500, 15500,
	        12600, 14000 });
	    values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030, 11200, 9500, 10500,
	        11600, 13500 });
	    int[] colors = new int[] { Color.BLUE, Color.CYAN };
	    XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
	    setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0.5,
	        12.5, 0, 24000, Color.GRAY, Color.LTGRAY);
	    renderer.setXLabels(12);
	    renderer.setYLabels(10);
	    renderer.setDisplayChartValues(true);
	    renderer.setXLabelsAlign(Align.LEFT);
	    renderer.setYLabelsAlign(Align.LEFT);
//	     renderer.setPanEnabled(false);
	    // renderer.setZoomEnabled(false);
	    renderer.setZoomRate(1.1f);
	    renderer.setBarSpacing(0.5f);
	    renderer.setOrientation(Orientation.VERTICAL);
	    return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
	        Type.STACKED);
	}
	
	public View getView(Context context)
	{
		String[] titles = new String[] { "2008", "2007" };
	    List<double[]> values = new ArrayList<double[]>();
	    values.add(new double[] { 14230, 12300, 14240, 15244, 15900, 19200, 22030, 21200, 19500, 15500,
	        12600, 14000 });
	    values.add(new double[] { 5230, 7300, 9240, 10540, 7900, 9200, 12030, 11200, 9500, 10500,
	        11600, 13500 });
	    int[] colors = new int[] { Color.BLUE, Color.CYAN };
	    XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
	    setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0.5,
	        12.5, 0, 24000, Color.GRAY, Color.LTGRAY);
	    renderer.setXLabels(12);
	    renderer.setYLabels(10);
	    renderer.setDisplayChartValues(true);
	    renderer.setXLabelsAlign(Align.LEFT);
	    renderer.setYLabelsAlign(Align.LEFT);
//	     renderer.setPanEnabled(false);
	    // renderer.setZoomEnabled(false);
	    renderer.setZoomRate(1.1f);
	    renderer.setBarSpacing(0.5f);
	    renderer.setOrientation(Orientation.VERTICAL);
	    return ChartFactory.getBarChartView(context, buildBarDataset(titles, values), renderer,
	        Type.STACKED);
	}

}
